package com.macro.mall.portal.controller;

import com.alibaba.fastjson.JSONObject;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.BmsNarratorThemeDetail;
import com.macro.mall.dto.BmsNarratorThemeParam;
import com.macro.mall.dto.BmsTourismProjectActivitiesDetail;
import com.macro.mall.dto.BmsTourismProjectActivitiesParam;
import com.macro.mall.model.BmsNarratorTheme;
import com.macro.mall.portal.dto.ActivictyApplicantDetail;
import com.macro.mall.portal.service.BmsNarratorThemeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@Api(tags = "BmsNarratorThemeController")
@Tag(name = "BmsNarratorThemeController", description = "讲解项目-主题")
@RequestMapping("/narratorTheme")
public class BmsNarratorThemeController {

    @Autowired
    private BmsNarratorThemeService bmsNarratorThemeService;

    @ApiOperation("分页查询讲解项目-主题")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsNarratorTheme>> getList(@RequestBody BmsNarratorThemeParam bmsNarratorThemeParam) {
        List<BmsNarratorTheme> bmsNarratorThemeList = bmsNarratorThemeService.getList(bmsNarratorThemeParam);
        return CommonResult.success(CommonPage.restPage(bmsNarratorThemeList));
    }

    @ApiOperation("根据id获取讲解项目-主题信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsNarratorThemeDetail> getItem(@PathVariable Long id) {
        BmsNarratorThemeDetail bmsNarratorThemeDetail = bmsNarratorThemeService.getItem(id);
        return CommonResult.success(bmsNarratorThemeDetail);
    }

    @ApiOperation("根据日期获取讲解报名详情")
    @RequestMapping(value = "/getCurrentDataApplicantDetail", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<List<ActivictyApplicantDetail>> getCurrentDataApplicantDetail(@RequestBody BmsNarratorThemeParam bmsNarratorThemeParam) {
        List<ActivictyApplicantDetail> activictyApplicantDetailList = bmsNarratorThemeService.getCurrentDataApplicantDetail(bmsNarratorThemeParam);
        return CommonResult.success(activictyApplicantDetailList);
    }

    @ApiOperation("获取某一时间段每天的预约状态")
    @RequestMapping(value = "/getDataPeriodApplicantDetail", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<List<JSONObject>> getDataPeriodApplicantDetail(@RequestBody BmsNarratorThemeParam bmsNarratorThemeParam) {
        List<JSONObject> periodApplicantDetail = bmsNarratorThemeService.getDataPeriodApplicantDetail(bmsNarratorThemeParam);
        return CommonResult.success(periodApplicantDetail);
    }

    @ApiOperation("获取小程序用户报名文旅项目-活动")
    @RequestMapping(value = "/getReserveProjectActivities", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsNarratorThemeDetail>> getReserveProjectActivities(@RequestBody BmsNarratorThemeParam bmsNarratorThemeParam) {
        List<BmsNarratorThemeDetail> reserveProjectActivities = bmsNarratorThemeService.getReserveProjectActivities(bmsNarratorThemeParam);
        return CommonResult.success(CommonPage.restPage(reserveProjectActivities));
    }

    @ApiOperation("获取小程序用户报名人数")
    @RequestMapping(value = "/getReserveProjectActivitiesCount", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Integer> getReserveProjectActivitiesCount(@RequestBody BmsNarratorThemeParam bmsNarratorThemeParam) {
        int count =  bmsNarratorThemeService.getReserveProjectActivitiesCount(bmsNarratorThemeParam);
        return CommonResult.success(count);
    }
}
